import requests


class XueQiu:
    def __init__(self, one_url, two_url):
        """
        创建session请求
        :param one_url: 创建session请求的URL
        :param two_url: 实际的请求请求的URL
        """
        self.one_url = one_url
        self.two_url = two_url
        self.headers = {
            'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/109.0.0.0 Safari/537.36',
        }
        self.session = requests.Session()

    def get_data(self):
        """
        获取指定URL的数据
        :return:返回请求结果的JSON数据
        """
        self.session.get(url=self.one_url, headers=self.headers)
        data = self.session.get(url=self.two_url, headers=self.headers).json()
        return data


if __name__ == "__main__":
    xueqiu = XueQiu("https://xueqiu.com/",
                    "https://xueqiu.com/statuses/hot/listV2.json?since_id=-1&max_id=531705&size=15")
    data = xueqiu.get_data()
    print(data)
